package service;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class BaseService {
   private SqlSessionFactory ssf;
   public <T> T getMapper(Class<T> c) throws IOException{
       InputStream in=Resources.getResourceAsStream("config.xml");
       ssf=new SqlSessionFactoryBuilder().build(in);
       SqlSession session=ssf.openSession();
       return  session.getMapper(c);
   }
}
